﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Chinook.Core.DomainModel;
using FluentNHibernate.Mapping;

namespace Chinook.Core.FNHMappings
{
    public class CustomerMap : ClassMap<Customer>
    {
       public CustomerMap()
        {
            //Table that has been referred to
            Table("Customer");

            Cache.Region("CacheCustomerMaster").ReadWrite();
           

            //Mapping for Primary key column
            Id(x => x.Id, "CustomerId").GeneratedBy.Identity();

            //Map table Columns to POCO Fields
            Map(x => x.LastName);
            Map(x => x.FirstName);
            Map(x => x.Address);
            Map(x => x.City);
            Map(x => x.Country);
            Map(x => x.PostalCode);
            Map(x => x.State);
            Map(x => x.Email);
            Map(x => x.Phone);
            Map(x => x.Fax);            
            //One-to-one relationship
            References<Employee>(x => x.SupportRepresentant, "SupportRepId").Cascade.None().Nullable().LazyLoad();
        }
    }
}
